//
//  DoctorListModel.m
//  International_Hospital
//
//  Created by 李建强 on 16/7/7.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "DoctorListModel.h"
#import "NetWorkTool.h"
@implementation DoctorListModel


+(instancetype)doctorModelWithDict:(NSDictionary *)dict{
    
    DoctorListModel *model = [[DoctorListModel alloc]init];
    [model setValuesForKeysWithDictionary:dict];
    return model;
}

-(NSArray *)doctorDataArray{
    
    NSString *path = [[NSBundle mainBundle]pathForResource:@"DoctorList.plist" ofType:nil];
    NSArray *tempArray = [NSArray arrayWithContentsOfFile:path];
    NSMutableArray *muArray = [NSMutableArray array];
    [tempArray enumerateObjectsUsingBlock:^(NSDictionary*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        DoctorListModel *model = [DoctorListModel doctorModelWithDict:obj];
        [muArray addObject:model];
    }];
    return muArray.copy;
    
    
}


-(void)dataSuccess:(successBlock)successBlock error:(errorBlock)errorBlock{
    [[NetWorkTool shareManager]POST_RequestWithUrlString:@"http://iosapi.itcast.cn/matchDoctors.json.php" parmas:@{@"ci1_id":@(1),@"ci2_id":@(3),@"ci3_id":@(3),@"diagnosis_type":@(0),@"page_size":@(15),@"is_confirmed":@(1),@"user_id":@(1000089), @"page":@(1),@"has_diagnosis":@(2)} successBloock:^(NSDictionary* responseObject) {
        NSArray*dataArray = responseObject[@"data"];
        
        NSMutableArray *muArray = [NSMutableArray array];
        [dataArray enumerateObjectsUsingBlock:^(NSDictionary*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
           
            DoctorListModel *model = [DoctorListModel doctorModelWithDict:obj];
            
            [muArray addObject:model];
            
        }];
        if (successBlock) {
            successBlock(muArray.copy);
        }
        
        
    } failureBlock:^(NSError *error) {
        
        errorBlock();
    }];
    
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}


@end
